package bitdata;


import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;

public class BitSetTest {
    public static void main(String[] args) {


        testBitMap();
    }

    public static void testBitMap(){

        // 范围
        int range = 100;
        // 数量
        int size = 10;

        BitSet bitSet = new BitSet();
        List<Integer> list = new ArrayList<>();


        for (int i = 0; i < size; i++){
            int random = (int)(Math.random() * range);
            bitSet.set(random);
            list.add(random);
        }

        System.out.println("产生的随机数 "+list);
        System.out.println("bitMap是1的个数 "+bitSet.cardinality());
        System.out.println("bitMap的size "+bitSet.size());
        System.out.println("bitMap的length "+bitSet.length());

        for (int i = 0; i < range; i++){
            if (!bitSet.get(i)){
                System.out.print(i+",");
            }
        }

    }
}
